package test;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Main0 {
	public static List<String> convertStringToList(String line) {
		Scanner in = new Scanner(line);
		List<String> li = new ArrayList<String>();
		while(in.hasNext()){
			li.add(in.next());
		}
	    in.close();
	    return li;
	}

	public static void remove(List<String> list, String str){
		while(list.indexOf(str) != -1){
			int x = list.indexOf(str);
			list.remove(x);
		}
	}

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(sc.hasNextLine()){
            List<String> list = convertStringToList(sc.nextLine());
            System.out.println(list);
            String word = sc.nextLine();
            remove(list,word);
            System.out.println(list);
        }
        sc.close();
    }
}
